let mysql = require('mysql')
exports.base = (sql, data, callback) => {
    let conn = mysql.createConnection({
        host: 'localhost',//本机链接
        user: 'root',
        password: '123456',
        port: '3306',
        database: 'class3'
    })
    conn.connect();
    //如果不存在，创建数据库test_database,数据库表Login
    conn.query("create table if not exists Login\
     (`username` varchar(16) unique not null,`password` varchar(16) not null);", (error, results, fields) => {
        if (error) throw error; {
            console.log(error)
        }
        console.log(results)
    })
    conn.query(sql, data, (error, results, fields) => {
        if (error) {
            console.log(error)
        }
        console.log(results)
        callback && callback(results, error)
    })
    conn.end();
}